import com.aspose.cells.Workbook;
import com.aspose.words.Document;
import com.aspose.words.SaveFormat;

import java.io.File;
import java.io.FileOutputStream;

public class Office2PdfTest {
    public static void main(String[] args) {
//        word("/Users/liuzy/Documents/附8-1：客服中心营销活动变更申请表-更新券名称.docx");
        xls("/Users/liuzy/Documents/正弘城美妆券.xlsx");
    }

    private static void word(String src) {
        File file = new File(src + ".pdf");
        try (FileOutputStream os = new FileOutputStream(file)) {
            long start = System.currentTimeMillis();
            Document doc = new Document(src);
            doc.save(os, SaveFormat.PDF);
            System.out.println("convert cost " + (System.currentTimeMillis() - start) + "ms");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private static void xls(String src) {
        File file = new File(src + ".pdf");
        try (FileOutputStream os = new FileOutputStream(file)) {
            long start = System.currentTimeMillis();
            Workbook doc = new Workbook(src);
            doc.save(os, SaveFormat.PDF);
            System.out.println("convert cost " + (System.currentTimeMillis() - start) + "ms");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
